<template>
	<view style="width:100%;
	overflow-x:hidden;padding-bottom: 200rpx;"> 
		<!-- 顶部背景图 -->
		 <!-- 顶部背景图 -->
		<view class="top_topNav" >
			<view class="user">
				<view class="img">
					<image class="avatar" :src="userInfo.avatar" mode="aspectFill" @click="showAvatar()"></image>
					<view class="img_2" v-if="userInfo">
						<view class="h1">
							<text>{{nickname}} <text class="dj" @click="toPages('/subone/user/user_level')">Lv.{{userInfo.rose_level}}</text></text>
							<view class="grzx" @click="center()">个人中心</view>
						</view>
						<view class="jindu" >
							<view :class="'jindu_'+userInfo.rose_level+''">
							</view>
						</view>
					</view>
					<view class="img_2" v-else>
						<view class="h1" style="line-height: 85rpx;" @click="is_login()">
							登录/注册
						</view>
						
					</view>
				</view>
				<view class="box">
					
				</view>
			</view>
		</view>
		
		
		<view class="zhong">
			<img class="zhong_img" src="https://oa.yuxiang123.cn/assets/task/shop/user_shop.png" mode="widthFix">
			
			<view class="zhong_title" @click="toPages('/merchant/shop/add_shop',1)" v-if="isHuaWei" >
				<view style="width: 10%;margin-left: 1%;">
					<img src="https://oa.yuxiang123.cn/assets/task/shop/shop_pb.png" mode="widthFix" style="width: 50rpx;height: 50rpx;">
				</view>
				<view style="width: 58%;line-height: 55rpx;">
					商家服务中心
				</view>
				<view style="width: 22%;line-height: 55rpx;">
					{{shop_type}}
				</view>
				<view style="width: 3%;margin-top: 7rpx;">
					<img src="https://oa.yuxiang123.cn/assets/task/shop/shop_you.png" mode="widthFix" style="width: 45rpx;height: 45rpx;position: relative;">
				</view>
			</view>
			<view class="zhong_title" @click="toPages('/merchant/shop/add_shop',1)" v-else>
				<view style="width: 10%;margin-left: 1%;">
					<img src="https://oa.yuxiang123.cn/assets/task/shop/shop_pb.png" mode="widthFix" style="width: 50rpx;height: 50rpx;">
				</view>
				<view style="width: 65%;line-height: 55rpx;">
					商家服务中心
				</view>
				<view style="width: 15%;line-height: 55rpx;">
					{{shop_type}}
				</view>
				<view style="width: 3%;margin-top: 7rpx;">
					<img src="https://oa.yuxiang123.cn/assets/task/shop/shop_you.png" mode="widthFix" style="width: 45rpx;height: 45rpx;position: relative;">
				</view>
			</view>
			<view class="zhong_tts" v-if="is_type == 1">
				<view style="    font-weight: 600;
				height: 60rpx;">
					我的账户
				</view>
				<view style="display: flex;">
					<view style="width: 30%;" v-if="meal_num > 0 || (meal_num == 0  && comment_num == 0)">
						<view style="    font-size: 24rpx;
						color: #9E9E9E;    height: 38rpx;">
							发帖套餐数量
						</view>
						<view style="    font-size: 44rpx;
						font-weight: 600;">
							{{meal_num}}
						</view>
					</view>
					<view style="width: 30%;"  v-if="comment_num > 0">
						<view style="    font-size: 24rpx;
						color: #9E9E9E;    height: 38rpx;">
							评论套餐数量
						</view>
						<view style="    font-size: 44rpx;
						font-weight: 600;">
							{{comment_num}}
						</view>
					</view>
					
				</view>
				
				<view class="zhong_butt" @click="toPages('/merchant/shop/meal')">充<text style="margin-left: 8rpx;">值</text> </view>
			</view>
			<view class="zhong_tts" v-if="is_type == 2">
				<view style="    font-weight: 600;
				height: 60rpx;">
					我的账户
				</view>
				<view style="    font-size: 22rpx;
				color: #9E9E9E;    height: 38rpx;">
					当前余额
				</view>
				<view style="    font-size: 44rpx;
				font-weight: 600;">
					{{userInfo.shop.balance ? userInfo.shop.balance : '0.00'}}
				</view>
				<view class="zhong_butt" @click="toPages('/merchant/shop/withdraw')">充值</view>
			</view>
			
		</view>
		<view style="width: 94%;margin-left: 3%;background: #fff;border-radius: 30rpx;margin-top: 32rpx;">
			<!-- 更多功能 -->
			<!-- <view class="order_block" @click="await()">
				<view class="order_status_nav1" >
					<view style="width: 10%;"><image  style="width: 50rpx;height: 50rpx;" class="icon" src="https://oa.yuxiang123.cn/assets/task/shop/fapiao.png"></image></view>
					<view style="width: 83%;">开具发票</view>
					<view style="width: 7%;color:#666;"><u-icon  name="arrow-right"></u-icon></view>
				</view>
			</view> -->
			<view class="order_block"  @click="toPages('/merchant/shop/ai_recharge')">
				<view class="order_status_nav1" >
					<view style="width: 10%;"><image  style="width: 50rpx;height: 50rpx;" class="icon" src="https://oa.yuxiang123.cn/assets/task/shop/chong_ai.png"></image></view>
					<view style="width: 83%;">AI套餐</view>
					<view style="width: 7%;color:#666;"><u-icon  name="arrow-right"></u-icon></view>
				</view>
			</view>
			<view class="order_block"  @click="toPages('/pages/order/orderList',0,false)">
				<view class="order_status_nav1" >
					<view style="width: 10%;"><image  style="width: 50rpx;height: 50rpx;" class="icon" src="https://oa.yuxiang123.cn/assets/task/shop/zhangdan.png"></image></view>
					<view style="width: 83%;">我的账单</view>
					<view style="width: 7%;color:#666;"><u-icon  name="arrow-right"></u-icon></view>
				</view>
			</view>
			<view class="order_block"  @click="toPages('/subone/user/invite',0,false)">
				<view class="order_status_nav1" >
					<view style="width: 10%;"><image  style="width: 50rpx;height: 50rpx;" class="icon" src="https://oa.yuxiang123.cn/assets/task/shop/yaoqing.png"></image></view>
					<view style="width: 83%;">邀请好友</view>
					<view style="width: 7%;color:#666;"><u-icon  name="arrow-right"></u-icon></view>
				</view>
			</view>
		</view>
		<view class="zhong_css" >
			<!-- <view class="order_block" style="padding: 20rpx 20rpx 10rpx 20rpx;">
				<view class="order_status_nav1" >
					<view style="width: 10%;"><image  style="width: 50rpx;height: 50rpx;" class="icon" src="https://oa.yuxiang123.cn/assets/task/shop/kefu.png"></image></view>
					<button type="default" open-type="contact" style="background-color: transparent;
					line-height: 50rpx;
					width: 83%;
					text-align: left;
					padding: 0;
					font-size: 34rpx !important; "  v-if="isHuaWei">
						<view style="width: 83%;">联系客服</view>
					</button>	
					<button type="default" open-type="contact" style="background-color: transparent;
					line-height: 50rpx;
					width: 83%;
					text-align: left;
					padding: 0;
					font-size: 30rpx !important; "  	v-else>
						<view style="width: 83%;">联系客服</view>
					</button>	
				
					<view style="width: 7%;color:#666;"><u-icon  name="arrow-right"></u-icon></view>
				</view>
			</view> -->
			<view class="order_block" style="padding: 20rpx 20rpx 10rpx 20rpx;" @click="get_qcode()">
				<view class="order_status_nav1" >
					<view style="width: 10%;"><image  style="width: 50rpx;height: 50rpx;" class="icon" src="https://oa.yuxiang123.cn/assets/task/shop/kefu.png"></image></view>
					<view style="width: 83%;">联系客服</view>
					<view style="width: 7%;color:#666;"><u-icon  name="arrow-right"></u-icon></view>
				</view>
			</view>
			<view class="order_block" style="padding: 20rpx 20rpx 10rpx 20rpx;" @click="toPages('/subone/user/question_task',0,false)">
				<view class="order_status_nav1" >
					<view style="width: 10%;"><image  style="width: 50rpx;height: 50rpx;" class="icon" src="https://oa.yuxiang123.cn/assets/task/shop/bangzhu.png"></image></view>
					<view style="width: 83%;">帮助中心</view>
					<view style="width: 7%;color:#666;"><u-icon  name="arrow-right"></u-icon></view>
				</view>
			</view>
		</view>
		<!-- <view class="zhong_css" >
			<view class="order_block" style="padding: 20rpx 20rpx 10rpx 20rpx;" @click="toPages('/merchant/issue/task_set',0,true)">
				<view class="order_status_nav1" >
					<view style="width: 10%;"><image  style="width: 50rpx;height: 50rpx;" class="icon" src="https://oa.yuxiang123.cn/assets/task/shop/shezhi.png"></image></view>
					<view style="width: 83%;">任务设置</view>
					<view style="width: 7%;color:#666;"><u-icon  name="arrow-right"></u-icon></view>
				</view>
			</view>
		</view> -->

		<!-- 弹窗 -->
		<view class="bigimg" v-if="is_showbigimg">
			<image class="close" src="/static/close_white.png" @click="closeBigimg()" ></image>
			<view class="bigimg_blank" @click="closeBigimg()" ></view>
			<image class="img" :src="userInfo.bgimg" mode="widthFix"></image>
			<view class="bigimg_blank" @click="closeBigimg()" ></view>
			<view class="bigimg_btn" @click="changeImgEvent()">
				更换背景
			</view>
		</view>
		<view class="bigavatar" v-if="is_showavatar">
			<image class="close" src="/static/close_white.png" @click="closeAvatar()"></image>
			<view class="bigimg_blank" @click="closeAvatar()" ></view>
			<image class="avatar" :src="userInfo.avatar" mode="widthFix"></image>
			<view class="bigimg_blank" @click="closeAvatar()" ></view>
			<view class="bigimg_btn" @click="changeAvatarEvent()">
				更换头像
			</view>
		</view>
		
		<u-popup v-model="show_haibao" mode="center" >
			<!-- #ifdef MP-WEIXIN -->
				<image class="haibao" :src="haibao" mode="aspectFill"  @click="clickImg(haibao)" style="background-color: none !important;"></image>
				<!-- <view class="haibao_btn" @click="download_haibao(1)">保存图片加好友</view> -->
			<!-- #endif -->
			<!-- #ifdef APP-PLUS || H5 -->
				<image class="haibao" :src="haibao"  mode="aspectFill" @click="clickImg()"></image>
				<view class="haibao_btn" >点击图片长按保存分享</view>
			<!-- #endif -->
		</u-popup>
		<!-- <view class="weidu1" :style="{left:left_+'rpx'}" v-if="is_read_count > 0">{{is_read_count}}</view> -->
		<tabbar :type="4" :showissue="showissue" @closeissue="closeissue" @openissue="openissue"></tabbar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				shop_type:'去申请',
				is_ios:'dq',
				left_:530,
				is_type:1,
				meal_num:0,
				comment_num:0,
				is_read_count:0,
				show_haibao:false,
				haibao:'https://oa.yuxiang123.cn/assets/task/shop/zhangyi.jpg',
				is_gzh:false,
				showissue:false,
				is_showbigimg:0,
				is_showavatar:0,
				saSale: '1',
				saStatus: '-1',
				titleList:['我的作品', '我的喜欢', '我的收藏'],
				current: 0,
				videoList:[],
				userInfo:'',
				page:1,
				pagesize: '7',
				statusBarHeight: 0,
				action_index:-1,
				Im:'',
				showissue:false,
				nickname:'',
				is_xcx:true,
				isHuaWei:false
			}
		},
		onShow() {
			this.userInfo = uni.getStorageSync('userInfo'); 
			
			if(this.userInfo){
				this.nickname = this.userInfo.nickname;
				this.getUserInfo();
				//this.get_is_read_count();
			}else{
				this.shop_type = '去申请';
			}
		},
		onShareAppMessage(e) {
			var that=this;
			return {
				title: '苏拉营销',
				path: '/pages/shop/shopClass',    // 全局分享的路径
			}
		},
		onLoad() {
			//判断是否是华为
			let isHuaWei= getApp().globalData.isHuaWei;
			if(isHuaWei){
				this.setData({
					isHuaWei: isHuaWei
				})
			}

			if(uni.getSystemInfoSync().platform == 'ios'){
				this.is_ios = '';
			}


			// #ifdef APP-PLUS ||H5
			if( uni.getSystemInfoSync().platform == 'ios'){
				this.left_ = 595;
			}else{
				this.left_ = 570;
			}
			this.is_xcx = false;
			// #endif
			this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';


			
		},
		onReachBottom() {
			if(this.page *  this.pagesize > this.videoList.length){
				return false
			}
			this.page++;
			this.$show();
			if(this.current == '0'){
				this.getShopList();
			}else if(this.current == '1'){
				this.getLoveList()
			}else if(this.current == '2'){
				this.getCollectList()
			}
		},
		methods: {
			get_qcode(){
				this.show_haibao = true;
			},
			is_login(){
				if(!this.userInfo){
					// #ifdef MP-WEIXIN
					var url  = '/subone/public/login';
					// #endif
					// #ifdef APP-PLUS  || H5
					var url  = '/subone/public/phone_login';
					// #endif
					uni.navigateTo({
						url:url
					})
				}
			},
			get_is_read_count(){
				var userInfo = uni.getStorageSync('userInfo');
				if(userInfo){
					var that = this;
					uni.request({
						url: 'https://oa.yuxiang123.cn/api/user/get_user_message_count',
						header: {
							"content-type": "application/x-www-form-urlencoded"
						},
						method: 'POST',
						data:{
							token:uni.getStorageSync('token'),
							user_id:userInfo.id,
						},
						success: (res) => {
							that.is_read_count = res.data.data;
						}
					})
				}
			},
			clickImg(url) {
				var that = this;
				// #ifdef MP-WEIXIN
				uni.previewImage({
					urls: [url]
				})
				// #endif
				// #ifdef  APP-PLUS
				uni.previewImage({
					urls: [url],
					longPressActions: {
						itemList: ['保存图片'],
						success: (data) => {
							if(!uni.getStorageSync('save_img_previewImage') && that.isHuaWei){
								uni.showModal({
									title: "获取你的相册权限",
									content: "将获取你的相册权限,用于储存图片到本地相册",
									success: function (res) {
										if (res.cancel) {
										} else if (res.confirm) {
											uni.setStorageSync('save_img_previewImage',1);
											uni.downloadFile({
												url: url,
												success: (res) => {
													//将临时路径保存到相册，即可在相册中查看图片
													uni.saveImageToPhotosAlbum({
														filePath: res.tempFilePath, //不支持网络地址
														success: function () {
															uni.showToast({
															title: '保存图片到相册成功',
															position: 'bottom'
															});
														},
														fail: (e) => {
															if(e.errCode == 12 &&  e.errMsg == 'saveImageToPhotosAlbum:fail No Permission'){
																uni.showModal({
																	content: '检测到您没打开相册权限，如需使用储存图片功能请前往设置开启相册权限？',
																	confirmText: "确认",
																	cancelText: '取消',
																})
															}
														}
													});
												}
											})
										}
									},
								});
							}else{
								uni.downloadFile({
									url: url,
									success: (res) => {
										//将临时路径保存到相册，即可在相册中查看图片
										uni.saveImageToPhotosAlbum({
											filePath: res.tempFilePath, //不支持网络地址
											success: function () {
												uni.showToast({
												title: '保存图片到相册成功',
												position: 'bottom'
												});
											},
											fail: (e) => {
												if(e.errCode == 12 &&  e.errMsg == 'saveImageToPhotosAlbum:fail No Permission'){
													uni.showModal({
														content: '检测到您没打开相册权限，如需使用储存图片功能请前往设置开启相册权限？',
														confirmText: "确认",
														cancelText: '取消',
													})
												}
											}
										});
									}
								})
							}
						}
					}
				})
				// #endif
			
			},
			download_haibao(type){
				if(type == 1){
					var url = this.haibao;
				}else{
					var url = 'https://oa.yuxiang123.cn/uploads/img/gzh.png';
				}
				var that=this;
				uni.getSetting({
	                 success(res) {
	                   if (!res.authSetting['scope.writePhotosAlbum']) {
		                     uni.authorize({
		                       scope: 'scope.writePhotosAlbum',
		                       success() {
			                         that.saveImgToLocal(url);
		                       },
		                       fail() {//这里是用户拒绝授权后的回调
		                           that.openSettingBtnHidden=false
		                       }
		                     })
	                   } else {//用户已经授权过了
							that.saveImgToLocal(url);
				       }
			        }
			    })
			},
			saveImgToLocal(){
				var that=this;
				uni.downloadFile({
					url: that.haibao,//图片地址
					success: (res) =>{
						if (res.statusCode === 200){
							uni.saveImageToPhotosAlbum({
								filePath: res.tempFilePath,
								success: function() {
									uni.showToast({
										title: "保存成功",
										icon: "none"
									});
									that.show_haibao = false;
								},
								fail: function() {
									uni.showToast({
										title: "保存失败",
										icon: "none"
									});
								}
							});
						} 
					}
				});
			},
			closeissue:function(){
				this.showissue=false;
			},
			openissue:function(){
				this.showissue=true;
			},
			
			center(){
				uni.navigateTo({
					url:'/subone/user/center'
				})
			},
			showBigimg(){				
				this.is_showbigimg=true;
			},
			closeBigimg(){
				this.is_showbigimg=false;
			},
			
			showAvatar(){
				if(!this.userInfo){
					// #ifdef MP-WEIXIN
					var url  = '/subone/public/login';
					// #endif
					// #ifdef APP-PLUS  || H5
					var url  = '/subone/public/phone_login';
					// #endif
					uni.navigateTo({
						url:url
					})
				}else{
					this.is_showavatar=true;
				}
			},
			closeAvatar(){
				this.is_showavatar=false;
			},
			getShopList:function(){
				this.$http.post('user/my_product',{
					user_id:this.userInfo.id,
					page:this.page,
					pagesize: this.pagesize
				}).then((res)=>{
					this.$hide()
					if(res.ret == 1){
						this.videoList = this.videoList.concat(res.data.my_product)
					}
					
				})
			},
			getLoveList:function(){
				this.$http.post('user/my_love',{
					user_id:this.userInfo.id,
					page:this.page,
					pagesize: this.pagesize
				}).then((res)=>{
					this.$hide()
					this.videoList = this.videoList.concat(res.data.my_love)
				})
			},
			getCollectList:function(){
				this.$http.post('user/my_collect',{
					user_id:this.userInfo.id,
					page:this.page,
					pagesize: this.pagesize
				}).then((res)=>{
					this.$hide()
					this.videoList = this.videoList.concat(res.data.my_collect)
				})
			},
		
			//获取用户信息并缓存到本地
			getUserInfo:function(){
				var that = this;
				uni.request({
					url: 'https://oa.yuxiang123.cn/api/user/homepage',
					header: {
						"content-type": "application/x-www-form-urlencoded"
					},
					method: 'POST',
					data:{
						token:uni.getStorageSync('token'),
						user_id:that.userInfo.id
					},
					success: (res) => {
						if(res.data.code == 1){
							uni.setStorageSync('userInfo', res.data.data.user);
							that.userInfo = res.data.data.user;
							that.nickname = that.userInfo.nickname;
							if(that.userInfo.shop){
								that.shop_type = '已通过';
								var meal_num = that.userInfo.shop.monthly_num + that.userInfo.shop.thirdpartnar_num + that.userInfo.shop.enemy_num;
								that.comment_num = that.userInfo.shop.comment_num;
								if(meal_num > 0){
									that.meal_num = meal_num;
								}else if(that.userInfo.shop.balance > 0 || that.userInfo.shop.id < 85){
									that.is_type = 2;
								}
							}else{
								if(that.userInfo.shop_status == 0){
									that.shop_type = '审核中';
								}else if(that.userInfo.shop_status == -2){
									that.shop_type = '已冻结';
								}
							}
						}
						that.sectionChange(that.current);
					}
				})

			},
			// 标题滑动赋值
			sectionChange(index) {
				this.videoList.length=0;
				this.page = 1;
				this.current = index;
				if(index == 0){
					//this.getShopList();
				}else if(index == 1){
					//this.getLoveList();
				}else if(index == 2){
					//this.getCollectList();
				}
			},
			toPages:function(url, id=0, is_login = true){
				if(is_login){
					if(!this.userInfo){
						url='/subone/public/login';
					}else if(!this.userInfo.shop){
						if(this.userInfo.shop_status == 0){
						this.$Toast('商家审核已提交,请等待审核');
							return false;
						}else  if(this.userInfo.shop_status == -2){
							this.$Toast('您已被冻结,请联系客服');
							return false;
						}else{
							url='/merchant/shop/add_shop';
						}
					}else if(this.userInfo.shop && this.userInfo.shop.status == 1 && id==1){
						this.$Toast('您已是商家');
						return false;
					}
				}
				if(url == '/pages/order/orderList'){
					uni.switchTab({
						url:url
					})
					return false;
				}
				if(id == '4' && id){
					uni.showModal({
						title: '提示',
						content: '您随时可以通过您注册的手机号收到的验证码登录到您的账户。如果您的账号不能正常登录，或者由于手机号变更不能正常登录，您可以通过苏拉APP【我】-【≡】-【意见反馈】，详细说明情况，我们会尽快为您处理。',
						showCancel: false,
						success: () => {}
					})
				}else{
					uni.navigateTo({
						url:url
					})
				}
				
			},
			toPages_banner_xcx:function(item){
				//banner跳转专用
				uni.navigateToMiniProgram({
					// appid  写你要跳转的小程序的 appid
					appId: item.app_appid,
					// 路径写  src下的路径,假如你跳转的是pages下的页面,就可以写pages/index
					path: item.xcx_path,
					extraData: {
						// 'type': 'out'
					},
					envVersion: 'release',
					success(res) {
					},
					fail(err) {
					}
				})
			},
			//退出登录
			outLogin:function(){
				uni.showModal({
				    title: '提示',
				    content: '确定要退出当前账号吗？',
				    success: function (res) {
				        if (res.confirm) {
							uni.clearStorageSync();
							uni.removeTabBarBadge({
								index:3
							});
							uni.removeTabBarBadge({
								index:4
							});
							uni.reLaunch({
								url:'/pages/shop/shopClass'
							})
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
			},
			changeImgEvent(){
				// #ifdef  APP-PLUS
				uni.chooseImage({
					count: 1, //默认9
					crop:{
						width:1000,
						height:550
					},
					success: function (res) {
						that.upImg(res.tempFilePaths[0],type)
					}
				});
				// #endif
				// #ifdef MP-WEIXIN
				uni.chooseImage({
					count: 1, //默认9
					success: function (res) {
						// 2 对获取到的图片进行裁剪
						wx.cropImage({
							src: res.tempFilePaths[0], // 图片路径
							cropScale: '16:9', // 裁剪比例
							success:function(res){
								that.upLoadImgEvent(res.tempFilePath,'bgimg')
							},
							complete: (res) => {
								console.log(res,"裁剪调用结束");
							}
						})
					}
				});
				// #endif
			},
			await(){
				this.$Toast('任务开发中,敬请期待');
			},
			changeAvatarEvent(){
				var that = this;
				// #ifdef  APP-PLUS
				if(!uni.getStorageSync('save_img_user')  && that.isHuaWei){
					uni.showModal({
						title: "获取你的相册/相机权限",
						content: "将获取你的相册/相机权限,用于上传头像",
						success: function (res) {
							if (res.cancel) {
							} else if (res.confirm) {
								uni.setStorageSync('save_img_user',1);
								uni.chooseImage({
									count: 1, //默认9
									crop:{
										width:300,
										height:300
									},
									success: function (res) {
										that.upLoadImgEvent(res.tempFilePaths[0],'avatar')
									},
									fail(e) {
										if(that.isHuaWei){
											if(e.errCode == 11 &&  e.errMsg == 'chooseImage:fail No Permission'){
												uni.showModal({
													content: '检测到您没打开相机权限，如需使用拍摄功能请前往设置开启相机权限？',
													confirmText: "确认",
													cancelText: '取消',
												})
											}else if(e.errCode == 12 &&  e.errMsg == 'chooseImage:fail No Permission'){
												uni.showModal({
													content: '检测到您没打开相册权限，如需使用相册选择功能请前往设置开启相册权限？',
													confirmText: "确认",
													cancelText: '取消',
												})
											}
										}
									}
								});
							}
						}
						
					});
				}else{
					uni.chooseImage({
						count: 1, //默认9
						crop:{
							width:300,
							height:300
						},
						success: function (res) {
							that.upLoadImgEvent(res.tempFilePaths[0],'avatar')
						},
						fail(e) {
							if(that.isHuaWei){
								if(e.errCode == 11 &&  e.errMsg == 'chooseImage:fail No Permission'){
									uni.showModal({
										content: '检测到您没打开相机权限，如需使用拍摄功能请前往设置开启相机权限？',
										confirmText: "确认",
										cancelText: '取消',
									})
								}else if(e.errCode == 12 &&  e.errMsg == 'chooseImage:fail No Permission'){
									uni.showModal({
										content: '检测到您没打开相册权限，如需使用相册选择功能请前往设置开启相册权限？',
										confirmText: "确认",
										cancelText: '取消',
									})
								}
							}
						}
					});
				}
 				// #endif
				// #ifdef MP-WEIXIN
				uni.chooseImage({
                    count: 1, //默认选取1张图片
                    success: function (res) {
						wx.cropImage({
							src: res.tempFilePaths[0], // 图片路径
							cropScale: '1:1', // 裁剪比例
							success:function(res){
								that.upLoadImgEvent(res.tempFilePath,'avatar')
							},
							complete: (res) => {
								console.log(res,"裁剪调用结束");
							}
						})
					}
				})
				// #endif
			},
			
			upLoadImgEvent(url, type){
				uni.uploadFile({
					url: 'https://oa.yuxiang123.cn/api/common/upload',
					filePath: url,
					name: 'file',
					success: (res) => {
						let result = JSON.parse(res.data)
						if(result.code == 1){
							this.changeUpLoadImg(result.data.fullurl, type)
						}else{
							uni.showToast({
								icon: 'none',
								title: '上传失败',
								success: () => {}
							})
						}
					}
				})
			},
			changeUpLoadImg(imgSrc, type){
				let params
				if(type == 'bgimg'){
					params = {token:uni.getStorageSync('token'),bgimg: imgSrc}
				}else if(type == 'avatar'){
					params = {token:uni.getStorageSync('token'),avatar: imgSrc}
				}
				uni.request({
					url: 'https://oa.yuxiang123.cn/api/user/profile_save',
					header: {
						"content-type": "application/x-www-form-urlencoded"
					},
					method: 'POST',
					data:params,
					success: (res) => {
						if(res.data.code == 1){
							uni.showToast({
								icon: 'none',
								title: res.data.msg,
								success: () => {
									this.getUserInfo();
									this.is_showbigimg=0;
									this.is_showavatar=0;
								}
							})
						}else{
							uni.showToast({
								icon: 'none',
								title: res.data.msg,
								success: () => {}
							})
						}
					}
				})
			},
		}
	}
</script>
<style>
	page{
		background-color: #f2f9fd;
	}
</style>
<style lang="scss" scoped>
	.dq{
		position: relative;
		top: 31rpx;color: #303030 !important;
	}
	button::after{
	border: none;
	background-color: none;
}



.dj{
	border-radius: 20px;
	background: linear-gradient(90deg, #8DA9FF 0%, #31D1C9 100%);
	color: #fff;
	font-size: 20rpx;
	margin-left: 20rpx;
	padding: 4rpx 25rpx;
	position: relative;
	top:-3rpx
}
.jindu{
	height: 20rpx;
	width: 200rpx;
	background: #fff;
	border-radius: 10rpx;
	margin-top: 20rpx;

	.jindu_1{
		height: 20rpx;
		width: 20%;
		background: #31D1C9;
		border-radius: 10rpx;
		margin-top: 20rpx;
	}
	.jindu_2{
		height: 20rpx;
		width: 40%;
		background: #31D1C9;
		border-radius: 10rpx;
		margin-top: 20rpx;
	}
	.jindu_3{
		height: 20rpx;
		width: 60%;
		background: #31D1C9;
		border-radius: 10rpx;
		margin-top: 20rpx;
	}
	.jindu_4{
		height: 20rpx;
		width: 80%;
		background: #31D1C9;
		border-radius: 10rpx;
		margin-top: 20rpx;
	}
	.jindu_5{
		height: 20rpx;
		width: 100%;
		background: #31D1C9;
		border-radius: 10rpx;
		margin-top: 20rpx;
	}

}


.top_topNav{
    padding-top: 94upx;
    background: url('https://oa.yuxiang123.cn/assets/task/shop/user_bann.png') no-repeat;
	padding-bottom: 10upx;
}
.haibao{width:500rpx;height:800rpx;}
.haibao_btn{width:100%;height:80rpx;line-height: 80rpx;background-color:#f60;color:#fff;text-align: center;}
	

	.zhong{
			height: 300rpx;
			margin-top: -25rpx;
			
		}
		.zhong_img{
			width: 94%;
			margin-left: 3%;
			position: relative;
		}
		.zhong_title{
			display: flex;
			flex-wrap: wrap;
			width: 90%;
			margin-left: 5%;
			margin-top: -100rpx;
			z-index: 1000;
			position: absolute;
			color: #F9DEAA;
		}
		.zhong_tts{
			width: 86%;
			margin-left: 3%;
			background: #fff;
			border-radius: 30rpx;
			position: absolute;
			//z-index: 10000;
			margin-top: -30rpx;
			padding: 4%;
		}
		.zhong_butt{
			width: 170rpx;
			background: #3662EC;
			color: #fff;
			text-align: center;
			height: 55rpx;
			line-height: 55rpx;
			border-radius: 40rpx;
			position: absolute;
			right: 30rpx;
			margin-top: -75rpx;
		}
		.zhong_css{
			width: 94%;
			margin-left: 3%;
			background: #fff;
			border-radius: 30rpx;
		}


	.bigimg{width:100%;height: 100%;position:fixed;left:0;top:0;z-index:888;background-color:#fce192;filter:(2px);text-align: center;}
	.bigimg .close{width:60upx;height:60upx; float:left;margin:60px 0 0 5%;}
	.bigimg .img{width:100%;}
	.bigimg .bigimg_blank{width:100%;height:32%;}
	.bigimg .bigimg_btn{width:90%;height: 40px;line-height: 40px;text-align: center;border-radius:3px;color:#1daafb;background-color:#fff; position: fixed;left:5%;bottom:10%;z-index:889;}

	.bigavatar{width:100%;height: 100%;position:fixed;left:0;top:0;z-index:888;background-color:#fce192;filter:(2px);text-align: center;}
	.bigavatar .close{width:60upx;height:60upx; float:left;margin:60px 0 0 5%;}
	.bigavatar .avatar{width:80%; margin:0 10%}
	.bigavatar .bigimg_blank{width:100%;height:25%;}
	.bigavatar .bigimg_btn{width:90%;height: 40px;line-height: 40px;text-align: center;border-radius:3px;color:#1daafb;background-color:#fff; position: fixed;left:5%;bottom:15%;z-index:889;}

	.bg{background-color: #f4f5f7;}

	
	.user{
		padding:30upx 0 0 30upx;
		position: relative;
		border-radius: 20rpx 20rpx 0 0;
		margin-top: 200rpx;
		.img{
			width: 100%;
			height: 160upx;
			margin-top: -160upx;
			z-index:88;
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			.avatar{
				width:120rpx;
				height:120rpx;
				border-radius: 50%;
				border:5upx solid #FFFFFF;
				margin-right:20rpx;
			}
			.img_2{
				width:80%;
				padding-top: 20rpx;
				.h1{
					width:100%; 
					height:40rpx;
					line-height: 40rpx;
					font-size:38rpx;
					display: flex;
					justify-content: space-between;
					font-weight: 600;
					.grzx{
						width: 200rpx;
						height: 65rpx;
						line-height: 65rpx;
						background-size: auto 20rpx;
						margin-top: 20rpx;
						margin-right: -10rpx;
						background: rgba(255, 255, 255, 0.60);
						text-align: center;
						border-radius: 40rpx 0 0 40rpx;
						font-size: 27rpx;
						color:#333;
						font-weight: 500;
					}
				}
				.h2{font-size:24rpx;line-height:55rpx; color:#fff;}
			}
			.level{width:100%;height:40rpx;
				.level_1.aixin{width:40rpx;height:40rpx;}
				.level_2.aixin{width:40rpx;height:40rpx;}
				.level_3.aixin{width:40rpx;height:40rpx;}
				.level_4.aixin{width:34rpx;height:34rpx;}
				.level_5.aixin{width:30rpx;height:30rpx;}
			}
		}
		.box{
			display: flex;
			text-align: center;
			border-radius:20rpx;
			margin-bottom:40rpx;
			.data{
				flex: 1;
				.num{
					font-size: 42upx;
					margin-top: 10upx;
					color:#303030;
					font-weight: 600;
					margin-bottom: 10rpx;
				}
				.text{
					font-size:26upx;
					color: #999;
				}
			}
			.line{
				width:1px;
				height: 30px;
				margin: 10px 0;
				border-right: 1px solid #dee1e6;
			}
		}
	}

	.order_block{margin:25rpx 12rpx 12rpx 12rpx;border-radius: 20rpx;overflow: hidden;padding: 20rpx 20rpx 10rpx 20rpx;}
	.order_title{font-size:32rpx;font-weight: 550;padding:30rpx ;}
	.order_status_nav{
	
		display: flex;
		flex-direction: row;
		justify-content:space-around;
		text-align: center; 
	}
	.order_status_nav .order_status{
		width: 100%;
    	display: inline-block;
	}
	.order_status_nav .order_status .icon{width:90rpx;height:90rpx;}
	.order_status_nav .order_status .status{width:100%;height:60rpx;line-height:40rpx; text-align: center;font-size: 26rpx;color:#303030; display: flex;flex-direction: column;margin-top: -5rpx;}
	.order_status_nav .order_status .num{width:40rpx;height: 40rpx;line-height: 40rpx;text-align: center;background-color:red;color:#fff;position: relative;top:-140rpx;z-index:2;border-radius:50%;font-size:24rpx;float:right;}

	.order_status_nav1{
		display: flex;flex-wrap: wrap;width: 100%;    line-height: 50rpx;
		flex-direction: row;
		justify-content:space-around;
		background-color: #fff;
	}
	.order_status_nav1 .order_status{
		width: 25%;
    	display: inline-block;
		text-align: center; 
	}
	.order_status_nav1 .order_status .icon{width:60rpx;height:60rpx;}
	.order_status_nav1 .order_status .status{width:100%;height:60rpx;line-height:40rpx; text-align: center;font-size: 26rpx;color:#303030; display: flex;flex-direction: column;}
	.order_status_nav1 .order_status .num{width:40rpx;height: 40rpx;line-height: 40rpx;text-align: center;background-color:red;color:#fff;position: relative;right:-10rpx;top:-120rpx;z-index:2;border-radius:50%;font-size:24rpx;float:right;}
	
</style>
